﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="dialog_select_coupons.aspx.cs" Inherits="Donal.Xms.Web.qianyi.dialog.dialog_select_coupons" %>

<%@ Import Namespace="Donal.Xms.Common" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>选择优惠券</title>
    <link rel="stylesheet" type="text/css" href="../skin/icon/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../skin/default/style.css" />
    <script type="text/javascript" charset="utf-8" src="../../scripts/jquery/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../js/common.js"></script>
    <script src="../../scripts/jquery/jquery.cookie.js"></script>

    <script type="text/javascript">
        var api = top.dialog.get(window); //获取父窗体对象
        var idc = String($.cookie("idc"));
        var item = "<tr><td align=\"center\"><input type=\"hidden\" name=\"hidCouponsId\" value=\"{coupon_id}\" />{title}</td><td align=\"center\">{amount}</td><td align=\"center\"><input type=\"text\" name=\"quantity\" maxlength=\"2\" class=\"td-input\" value=\"1\" onchange=\"changeNum(this);\" onkeydown=\"return checkNumber(event);\" /></td><td align=\"center\">{status}</td><td style=\"white-space: inherit; word-break: break-all;\">{contents}</td><td  align=\"center\"><a style=\"color: blue; cursor: pointer;\" onclick=\"delTr(this);\">删除</a></td></tr>";

        $(function () {
            //设置按钮及事件
            api.button([{
                value: '确定',
                callback: function () {
                    submitForm();
                    return false;
                },
                autofocus: true
            }, {
                value: '取消',
                callback: function () { }
            }
            ]);

            //初始化已选择的类别
            $(api.data).find("input[name='hidCouponsId']").each(function () {
                var itemId = $(this).val();
                $(".checkall").each(function () {
                    if ($(this).attr("id") == itemId) {
                        $(this).prop('checked', true);
                    }
                });
            });

            function submitForm() {
                $(api.data).empty();
                $(".checkall").each(function () {
                    if ($(this).is(':checked')) {
                        $(api.data).append(
                            item.replace('{coupon_id}', $(this).attr('id'))
                                .replace('{title}', $(this).attr('name'))
                                .replace('{amount}', $(this).val())
                                .replace('{status}', $(this).siblings("input[type=hidden]").attr("name"))
                                .replace('{contents}', $(this).siblings("input[type=hidden]").val())
                        );
                    }
                });

                api.close().remove();
            };

        });

    </script>
    <style>
        div.default {
            margin: 0;
            padding: 0;
            font-family: "Microsoft YaHei",Verdana;
            font-size: 12px;
        }

            div.default a, div.default span {
                display: block;
                float: left;
                margin: 2px 0 0 -1px;
                padding: 4px 12px;
                line-height: 20px;
                height: 20px;
                border: 1px solid #e1e1e1;
                background: #fff;
                color: #333;
                text-decoration: none;
            }

                div.default span:first-child {
                    border-left: 1px solid #e1e1e1;
                }

                div.default a:hover {
                    color: #666;
                    background: #eee;
                }

                div.default span.current {
                    color: #fff;
                    background: #488FCD;
                    border-color: #488FCD;
                }

                div.default span.disabled {
                    color: #999;
                    background: #fff;
                }

        .keywords {
            margin: 1px;
            padding: 4px;
            min-height: 20px;
            line-height: 20px;
            border: 1px solid #eee;
            background: #fff;
            vertical-align: middle;
        }
    </style>
</head>


<body>
    <form id="form1" runat="server">
        <div class="div-content">
            <dl>
                <dt>过滤</dt>
                <dd>
                    <div class="rule-single-select">
                        <asp:DropDownList ID="ddlExpiration_form" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlExpiration_form_SelectedIndexChanged">
                            <asp:ListItem Value="" Selected="True">失效形式</asp:ListItem>
                            <asp:ListItem Value="yb">永不过期</asp:ListItem>
                            <asp:ListItem Value="zd">自动过期</asp:ListItem>
                            <asp:ListItem Value="st">指定天数后过期</asp:ListItem>
                        </asp:DropDownList>
                    </div>

                    <asp:TextBox ID="txtKeywords" runat="server" CssClass="keywords" />
                    <asp:LinkButton ID="lbtnSearch" runat="server" CssClass="btn-search" OnClick="lbtnSearch_Click"><i class="iconfont icon-search"></i></asp:LinkButton>
                </dd>
            </dl>

            <dl>
                <dt>列表</dt>
                <dd>
                    <div style="padding-right: 50px; width: 600px;">
                        <table border="0" cellspacing="0" cellpadding="0" class="border-table" style="width: 100%;">
                            <thead>
                                <tr>
                                    <th style="width: 40px;">选择</th>
                                    <th style="width: 100px;">名称</th>
                                    <th style="width: 80px;">价格</th>
                                    <th>描述</th>
                                </tr>
                            </thead>
                            <tbody id="var_box">

                                <asp:Repeater ID="rptList" runat="server">
                                    <ItemTemplate>
                                        <tr>
                                            <td style="text-align: center;">
                                                <input type="hidden" name="<%#Eval("status").ToString()=="1"?"禁用":"正常" %>" value="<%#Eval("contents") %>" />
                                                <input type="checkbox" id="<%#Eval("id")%>" value="<%#Eval("amount")%>" name="<%#Eval("title") %>" class="checkall" />
                                            </td>
                                            <td style="text-align: left; word-break: break-all; width: 250px; white-space: inherit; line-height: 16px;">
                                                <%#Eval("title")%></td>
                                            <td style="text-align: center;">￥<%#Eval("amount")%>
                                            </td>
                                            <td style="text-align: left; word-break: break-all; width: 380px; white-space: inherit; line-height: 16px;">
                                                <%#Eval("contents")%></td>
                                        </tr>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </tbody>
                        </table>
                    </div>
                </dd>
            </dl>
        </div>

        <!--内容底部-->
        <div class="line20"></div>
        <div class="pagelist">
            <div class="l-btns" style="margin-left:10px;">
                <span>显示</span><asp:TextBox ID="txtPageNum" runat="server" CssClass="pagenum" onkeydown="return checkNumber(event);"
                    OnTextChanged="txtPageNum_TextChanged" AutoPostBack="True"></asp:TextBox><span>条/页</span>
            </div>
            <div id="PageContent" runat="server" class="default"></div>
        </div>
        <!--/内容底部-->
    </form>
</body>
</html>
